package com.example.houseman.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 方向类型
 *
 * @author Administrator
 */
public enum DirectionType {
    EAST("东", 1),
    SOURTH("南", 2),
    WEST("西", 3),
    NORTH("北", 4),
    EASTSOURTH("东南", 5),
    EASTNORTH("东北", 6),
    WESTSOURTH("西南", 7),
    WESTNORTH("西北", 8);

    @JsonValue
    private String name;

    @EnumValue
    private int index;

    private DirectionType(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static String getName(int index) {
        for (DirectionType c : DirectionType.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

}
